package com.example.warehousems.dao;

import com.example.warehousems.dao.model.Message;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

public interface MessageRepository extends JpaRepository<Message, Integer> {
    List<Message> findAllByIsReadOrderByTimeDesc(int isRead);
    List<Message> findByUserIdAndIsReadOrderByTimeDesc(Integer userId, int i);

    List<Message> findByIdIn(int[] ids);

    List<Message> findTop3ByUserIdAndIsReadOrderByTimeDesc(Integer userId, Integer isRead);

    List<Message> findTop3ByIsReadOrderByTimeDesc(Integer isRead);
    Page<Message> findByUserId(int userId, Pageable pageable);
}
